package cn.jhc.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jhc.bean.Author;
import cn.jhc.bean.Publisher;
import cn.jhc.dao.AuthorDAO;
import cn.jhc.dao.DaoType;
import cn.jhc.dao.PublisherDAO;
import cn.jhc.factory.DAOFactory;

/**
 * Servlet implementation class ShowAuthorsServlet
 */
@WebServlet("/showauthors.htm")
public class ShowAuthorsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		List<Author> authorlist = new ArrayList();
		AuthorDAO adao = (AuthorDAO)DAOFactory.getDao(DaoType.AUTHOR);
		authorlist = adao.getAll();
		request.setAttribute("authorlist", authorlist);
		request.getRequestDispatcher("/admin/admin.jsp?body=/tiles/showAuthors.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	

}
